package com.flexcloudsdk.channel;
import java.util.logging.Logger;

import com.google.appengine.api.channel.ChannelMessage;

public class CloudChannelMessage {
	private static final Logger log = Logger.getLogger(CloudChannelMessage.class.getName());

	private ChannelMessage channelMessage = null;
	private String sourceClass;
	private String sourceMethod;

	public CloudChannelMessage() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudChannelMessage.class.getName();
		log.info("CloudChannelMessage has been created by BlazeDS");
	}

	public void craeteMessage(String clientId, String message) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		channelMessage = new ChannelMessage(clientId, message);
	}

	public String getClientId() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("executing: " + sourceClass + "." + sourceMethod);
		return channelMessage.getClientId();
	}

	public String getMessage() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.warning("executing: " + sourceClass + "." + sourceMethod);
		return channelMessage.getMessage();
	}

}
